﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:SilverlightSEO"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
             xmlns:ga="clr-namespace:Google.WebAnalytics;assembly=Google.WebAnalytics" xmlns:mwab="clr-namespace:Microsoft.WebAnalytics.Behaviors;assembly=Microsoft.WebAnalytics.Behaviors" xmlns:mwad="clr-namespace:Microsoft.WebAnalytics.Data;assembly=Microsoft.WebAnalytics"
             x:Class="SilverlightSEO.NavigationMenuItem">

    <UserControl.Resources>
        <local:TitleUrlConverter x:Key="TitleConverter" />
        <Style x:Key="MenuItemHyperlinkButtonStyle" TargetType="HyperlinkButton">
        	<Setter Property="Foreground" Value="#FF73A9D8"/>
        	<Setter Property="Padding" Value="2,0,2,0"/>
        	<Setter Property="Cursor" Value="Hand"/>
        	<Setter Property="HorizontalContentAlignment" Value="Left"/>
        	<Setter Property="VerticalContentAlignment" Value="Top"/>
        	<Setter Property="Background" Value="Transparent"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="HyperlinkButton">
        				<Grid Cursor="{TemplateBinding Cursor}" Background="{TemplateBinding Background}">
        					<VisualStateManager.VisualStateGroups>
        						<VisualStateGroup x:Name="CommonStates">
        							<VisualState x:Name="Normal"/>
        							<VisualState x:Name="MouseOver">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="UnderlineTextBlock" Storyboard.TargetProperty="Visibility">
        										<DiscreteObjectKeyFrame KeyTime="0">
        											<DiscreteObjectKeyFrame.Value>
        												<Visibility>Visible</Visibility>
        											</DiscreteObjectKeyFrame.Value>
        										</DiscreteObjectKeyFrame>
        									</ObjectAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Pressed">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="UnderlineTextBlock" Storyboard.TargetProperty="Visibility">
        										<DiscreteObjectKeyFrame KeyTime="0">
        											<DiscreteObjectKeyFrame.Value>
        												<Visibility>Visible</Visibility>
        											</DiscreteObjectKeyFrame.Value>
        										</DiscreteObjectKeyFrame>
        									</ObjectAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Disabled">
        								<Storyboard>
        									<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="Visibility">
        										<DiscreteObjectKeyFrame KeyTime="0">
        											<DiscreteObjectKeyFrame.Value>
        												<Visibility>Visible</Visibility>
        											</DiscreteObjectKeyFrame.Value>
        										</DiscreteObjectKeyFrame>
        									</ObjectAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        						</VisualStateGroup>
        						<VisualStateGroup x:Name="FocusStates">
        							<VisualState x:Name="Focused">
        								<Storyboard>
        									<DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
        										<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
        									</DoubleAnimationUsingKeyFrames>
        								</Storyboard>
        							</VisualState>
        							<VisualState x:Name="Unfocused"/>
        						</VisualStateGroup>
        					</VisualStateManager.VisualStateGroups>
        					<TextBlock x:Name="UnderlineTextBlock" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" Text="{TemplateBinding Content}" TextDecorations="Underline" Foreground="{x:Null}"/>
        					<TextBlock x:Name="DisabledOverlay" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" Canvas.ZIndex="1" Foreground="#FFAAAAAA" Text="{TemplateBinding Content}"/>
        					<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
        					<Rectangle x:Name="FocusVisualElement" StrokeThickness="1" IsHitTestVisible="false" Opacity="0"/>
        				</Grid>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </UserControl.Resources>
        <StackPanel x:Name="LayoutRoot"
                Orientation="Vertical"
                RenderTransformOrigin="0.5,0.5">
        <StackPanel.RenderTransform>
            <TransformGroup>
                <ScaleTransform />
                <SkewTransform />
                <RotateTransform />
                <TranslateTransform />
            </TransformGroup>
        </StackPanel.RenderTransform>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="LinkStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="00:00:00.3000000">
                        <VisualTransition.GeneratedEasingFunction>
                            <CircleEase EasingMode="EaseOut" />
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="MouseOver">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="image"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1.3" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="image"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1.3" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="textBlock"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1.3" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="textBlock"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1.3" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="LayoutRoot"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="20" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="MouseOut">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="image"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="image"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="textBlock"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                       Duration="00:00:00.0010000"
                                                       Storyboard.TargetName="textBlock"
                                                       Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <EasingDoubleKeyFrame KeyTime="00:00:00"
                                                  Value="1" />
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Active">
                	<Storyboard>
                		<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
                			<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                		</DoubleAnimationUsingKeyFrames>
                		<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                			<EasingColorKeyFrame KeyTime="00:00:00" Value="#FF890208"/>
                		</ColorAnimationUsingKeyFrames>
                	</Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseEnter">
                <ic:GoToStateAction StateName="MouseOver" />
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseLeave">
                <ic:GoToStateAction StateName="MouseOut" />
            </i:EventTrigger>
            <i:EventTrigger EventName="MouseLeftButtonUp">
            	<ic:GoToStateAction StateName="Active"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
        	<i:Interaction.Behaviors>
        		<ga:GoogleAnalytics WebPropertyId="UA-101702-16"/>
        	</i:Interaction.Behaviors>
        <Border x:Name="border" BorderBrush="#00890208" BorderThickness="1" CornerRadius="3">
        		<HyperlinkButton x:Name="LinkButton" NavigateUri="{Binding Title, Converter={StaticResource TitleConverter}}" Style="{StaticResource MenuItemHyperlinkButtonStyle}" Foreground="{StaticResource NavigationItemBrush}">

        			<i:Interaction.Triggers>
        				<i:EventTrigger EventName="Click">
        					<mwab:TrackAction x:Name="GoogleTrackAction" Category="PageClick">
        						<mwab:TrackAction.CustomProperties>
        							<mwad:PropertyValue x:Name="PageNameValue" PropertyName="PageName"/>
        						</mwab:TrackAction.CustomProperties>
        					</mwab:TrackAction>
        				</i:EventTrigger>
        			</i:Interaction.Triggers>

        			<StackPanel x:Name="ItemPanel">
        				<Image x:Name="image"
        					Source="../images/image01.gif"
        					RenderTransformOrigin="0.5,0.5">
        					<Image.RenderTransform>
        						<TransformGroup>
        							<ScaleTransform />
        							<SkewTransform />
        							<RotateTransform />
        							<TranslateTransform />
        						</TransformGroup>
        					</Image.RenderTransform>
        				</Image>
        				<TextBlock x:Name="textBlock"
        					Text="{Binding Title}"
        					RenderTransformOrigin="0.5,0.5">
        					<TextBlock.RenderTransform>
        						<TransformGroup>
        							<ScaleTransform />
        							<SkewTransform />
        							<RotateTransform />
        							<TranslateTransform />
        						</TransformGroup>
        					</TextBlock.RenderTransform>
        				</TextBlock>
        			</StackPanel>

        		</HyperlinkButton>
        	</Border>
    </StackPanel>

</UserControl>
